<?php

class  HQ_Controller  extends  CI_Controller  {

    function HQ_Controller() {
	    // For PHP4 compatibility
	    $this->__construct();
	    register_shutdown_function(array(&$this, '__destruct'));
    }

	function __construct() {
		parent::__construct();
		if($this->config->item('log_sql') == TRUE) {
		    $this->hq_db->log_queries($this->config->item('log_sql_type'));
		}
		//$this->load->library('hq_db');
		if($_SERVER['REMOTE_ADDR'] == '127.0.0.1') {
		    // Always enable profiler in dev
			$this->output->enable_profiler(PROFILER);
			$this->load->helper('fb');
			$this->config->set_item('log_threshold',4);
		}
	}

	function __destruct() {	
        // SQL query logging
		if($this->config->item('log_sql') == TRUE) {
		    $this->hq_db->log_queries($this->config->item('log_sql_type'));
		}
	}
}